package modle;

import java.io.*;
import java.util.ArrayList;

public class Dao {

	public static ArrayList<Staff> staffs = new ArrayList<Staff>();

	public Dao() {
		new GetResource();

	}

	public static void ToStaff() {
		for (String temp : GetResource.StrStu) {
			String[] TmpStr = temp.split(":");
			Staff TmpStaff = new Staff();
			TmpStaff.setPayrpollNum(TmpStr[0]);
			TmpStaff.setPhone(TmpStr[1]);
			TmpStaff.setLastname(TmpStr[2]);
			TmpStaff.setFirstname(TmpStr[3]);
			TmpStaff.setDepartment(TmpStr[4]);
			TmpStaff.setTitle(TmpStr[5]);
			TmpStaff.setHiderDate(TmpStr[6]);
			staffs.add(TmpStaff);
		}

	}
	static public void update()
	{
		BufferedWriter bufferedWriter = null;
		try {
			File file = new File("E:/resource.txt");
			Writer writer=new FileWriter(file);
			bufferedWriter = new BufferedWriter(writer);
			String tempString = null;
			int i=0;
			for (String temp : GetResource.StrStu)
			{
				i++;
				if(i!=GetResource.StrStu.size())
				{
					bufferedWriter.write(temp+"\r\n");
				}
				else
				{
					bufferedWriter.write(temp);
				}
				}
			}
		 catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (bufferedWriter!= null) {
				try {
					bufferedWriter.close();
				} catch (IOException e1) {
				}

			}
		}
		staffs.removeAll(staffs);
		ToStaff();
	}

}
